package com.asion.vmovie.fragment;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;

import com.asion.vmovie.R;
import com.asion.vmovie.adapters.HomeViewAdapter;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by asion on 16-10-17.
 */

public class HomeFragment extends BaseFragment {

    ImageView homeSide;
    @BindView(R.id.home_tablayout)
    TabLayout homeTablayout;
    @BindView(R.id.home_search)
    ImageView homeSearch;
    @BindView(R.id.home_viewpager)
    ViewPager homeViewpager;

    @Override
    protected int getLayoutResource() {
        return R.layout.home_fragment;
    }

    @Override
    public void initPresenter() {

    }
    private String[] titles = {"最新","频道"};
    private List<Fragment> fragments = new ArrayList<>();

    @Override
    protected void initView() {
        fragments.add(NewsFragment.newInstance());
        fragments.add(PingDaoFragment.newInstance());
        homeViewpager.setAdapter(new HomeViewAdapter(getFragmentManager(),titles,fragments));
        homeTablayout.setupWithViewPager(homeViewpager);
    }

    @OnClick({ R.id.home_search})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.home_search:
                EventBus.getDefault().post("search");
                break;
        }
    }
}
